//
//  ViewController.m
//  02-UIViewController
//
//  Created by 冀永金 on 16/7/15.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "ViewController.h"
#import "PresentViewController.h"
@interface ViewController ()
@property (nonatomic,strong) UIView *subView;
@end

@implementation ViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // 不要再这个方法中 去加载视图
        // 在这个方法中去初始化数据相关的内容 （数据容易丢失）
        
    }
    return self;
}




// loadView 加载UIViewController中的View
// UINavigation
// UITableViewController 在loadView中 给重写赋值了
- (void)loadView {
    [super loadView];
   // NSLog(@"loadView");
}
// view 已经加载
// 所有自定义的视图已加载
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor cyanColor];
    // 模态
    //self.view = nil;
   // NSLog(@"%@",self.view);
    
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    PresentViewController *present = [[PresentViewController alloc]init];
    // 模态的效果
    //UIModalTransitionStyleCoverVertical  默认 上到下
//    UIModalTransitionStyleFlipHorizontal 左右翻页
//    UIModalTransitionStyleCrossDissolve, 渐变
//    UIModalTransitionStylePartialCurl 翻书效果
    present.modalTransitionStyle = 3;
    [self presentViewController:present animated:YES completion:^{
        
    }];
}






// 注意： init loadview viewDidLoad 只执行一次
// 懒加载
- (UIView *)subView {
    if (_subView == nil) {
        _subView = [UIView new];
        [self loadView];
    }
    return _subView;
}


// 视图将要出现
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}
// 视图已经出现
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
// 视图将要消失
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}
// 视图已经消失
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}

// 接受到内存警告时，执行的方法
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    // 释放部分内存资源
    //  把显示在屏幕上的资源置空
}

@end
